home *** CD-ROM | disk | FTP | other *** search
/ PC Basics 53 / PC Basics Issue 53.iso / Software / Internet / Invboard.exe / PC Basics 53 / Invboard / upload / sources / Help.php < prev    next >
Encoding:
PHP Script  |  2002-06-12  |  5.1 KB  |  184 lines

  1. <?php
  2.  
  3. /*
  4. +--------------------------------------------------------------------------
  5. |   IBFORUMS v1
  6. |   ========================================
  7. |   by Matthew Mecham and David Baxter
  8. |   (c) 2001,2002 IBForums
  9. |   http://www.ibforums.com
  10. |   ========================================
  11. |   Web: http://www.ibforums.com
  12. |   Email: phpboards@ibforums.com
  13. |   Licence Info: phpib-licence@ibforums.com
  14. +---------------------------------------------------------------------------
  15. |
  16. |   > Access the help files
  17. |   > Module written by Matt Mecham
  18. |   > Date started: 24th February 2002
  19. |
  20. |    > Module Version Number: 1.0.0
  21. +--------------------------------------------------------------------------
  22. */
  23.  
  24.  
  25. $idx = new Help;
  26.  
  27. class Help {
  28.  
  29.     var $output     = "";
  30.     var $page_title = "";
  31.     var $nav        = array();
  32.     var $html       = "";
  33.  
  34.  
  35.     
  36.     function Help() {
  37.         global $ibforums, $DB, $std, $print;
  38.         
  39.         
  40.         if ($ibforums->input['CODE'] == "") $ibforums->input['CODE'] = '00';
  41.         
  42.         //--------------------------------------------
  43.         // Require the HTML and language modules
  44.         //--------------------------------------------
  45.         
  46.         $ibforums->lang = $std->load_words($ibforums->lang, 'lang_help', $ibforums->lang_id );
  47.         
  48.         require "./Skin/".$ibforums->skin_id."/skin_help.php";
  49.         
  50.         $this->html = new skin_help();
  51.         
  52.         $this->base_url        = "{$ibforums->vars['board_url']}/index.{$ibforums->vars['php_ext']}?s={$ibforums->session_id}";
  53.         
  54.         
  55.         
  56.         //--------------------------------------------
  57.         // What to do?
  58.         //--------------------------------------------
  59.         
  60.         switch($ibforums->input['CODE']) {
  61.             case '01':
  62.                 $this->show_section();
  63.                 break;
  64.             case '02':
  65.                 $this->do_search();
  66.                 break;
  67.             default:
  68.                 $this->show_titles();
  69.                 break;
  70.         }
  71.         
  72.         // If we have any HTML to print, do so...
  73.         
  74.         $print->add_output("$this->output");
  75.         $print->do_output( array( 'TITLE' => $this->page_title, 'JS' => 0, NAV => $this->nav ) );
  76.             
  77.      }
  78.      
  79.      function show_titles() {
  80.          global $ibforums, $DB, $std;
  81.          
  82.          $seen = array();
  83.          
  84.          $this->output = $this->html->start( $ibforums->lang['page_title'], $ibforums->lang['help_txt'], $ibforums->lang['choose_file'] );
  85.          
  86.          $DB->query("SELECT id, title, description from ibf_faq ORDER BY title ASC");
  87.          
  88.          $cnt = 0;
  89.          
  90.          while ($row = $DB->fetch_row() ) {
  91.          
  92.              if (isset($seen[ $row['title'] ]) ) {
  93.                  continue;
  94.              } else {
  95.                  $seen[ $row['title'] ] = 1;
  96.              }
  97.              
  98.              $row['CELL_COLOUR'] = $cnt % 2 ? 'row1' : 'row2';
  99.              
  100.              $cnt++;
  101.              
  102.              $this->output .= $this->html->row($row);
  103.              
  104.          }
  105.          
  106.          $this->output .= $this->html->end();
  107.          
  108.          $this->page_title = $ibforums->lang['page_title'];
  109.          $this->nav        = array( $ibforums->lang['page_title'] );
  110.          
  111.      }
  112.      
  113.      function show_section() {
  114.          global $ibforums, $DB, $std;
  115.          
  116.          $id = $ibforums->input['HID'];
  117.          
  118.          if (! preg_match( "/^(\d+)$/" , $id ) ) {
  119.              $std->Error( array( LEVEL => 1, MSG => 'no_search_id') );
  120.          }
  121.          
  122.          $DB->query("SELECT id, title, text from ibf_faq WHERE ID='$id'");
  123.          $topic = $DB->fetch_row();
  124.          
  125.          $this->output  = $this->html->start( $ibforums->lang['help_topic'], $ibforums->lang['topic_text'], $topic['title'] );
  126.          $this->output .= $this->html->display( $std->text_tidy( $topic['text'] ) );
  127.  
  128.          $this->output .= $this->html->end();
  129.          
  130.          $this->page_title = $ibforums->lang['help_topic'];
  131.          $this->nav        = array( "<a href='{$this->base_url}&act=Help'>{$ibforums->lang['help_topics']}</a>", $ibforums->lang['help_topic'] );
  132.          
  133.      }        
  134.     
  135.      function do_search() {
  136.          global $ibforums, $DB, $std;
  137.          
  138.          if (empty( $ibforums->input['search_q'] ) ) {
  139.              $std->Error( array( LEVEL => 1, MSG => 'search_no_input') );
  140.          }
  141.          
  142.          $search_string = strtolower( str_replace( "*" , "%", $ibforums->input['search_q'] ) );
  143.          $search_string = preg_replace( "/[<>\!\@รบ\$\^&\+\=\=\[\]\{\}\(\)\"':;\.,\/]/", "", $search_string );
  144.          
  145.          $seen = array();
  146.          
  147.          $this->output = $this->html->start( $ibforums->lang['search_results'], $ibforums->lang['results_txt'], $ibforums->lang['search_results'] );
  148.          
  149.          $DB->query("SELECT id, title from ibf_faq WHERE LOWER(title) LIKE '%$search_string%' or LOWER(text) LIKE '%$search_string%' ORDER BY title ASC");
  150.          
  151.          $cnt = 0;
  152.          
  153.          while ($row = $DB->fetch_row() ) {
  154.          
  155.              if (isset($seen[ $row['title'] ]) ) {
  156.                  continue;
  157.              } else {
  158.                  $seen[ $row['title'] ] = 1;
  159.              }
  160.              
  161.              $row['CELL_COLOUR'] = $cnt % 2 ? 'row1' : 'row2';
  162.              
  163.              $cnt++;
  164.              
  165.              $this->output .= $this->html->row($row);
  166.              
  167.          }
  168.          
  169.          if ($cnt == 0) {
  170.              $this->output .= $this->html->no_results();
  171.          }
  172.          
  173.          $this->output .= $this->html->end();
  174.          
  175.          $this->page_title = $ibforums->lang['page_title'];
  176.          $this->nav        = array( "<a href='{$this->base_url}&act=Help'>{$ibforums->lang['help_topics']}</a>", $ibforums->lang['results_title'] );
  177.          
  178.      }
  179.  
  180.         
  181. }
  182.  
  183. ?>
  184.